package ace.module.stock.core.impl.dao.aggregate;

import ace.module.stock.api.enums.WmsStockRecordActionTypeEnum;
import ace.module.stock.core.impl.dao.entity.WmsStock;
import ace.module.stock.core.impl.dao.entity.WmsStockBatchRecord;
import ace.module.stock.core.impl.dao.entity.WmsStockRecord;
import java.util.List;

/**
 * 库存 aggregate.
 *
 * @author Caspar
 */
public interface WmsStockAggregate {

  /**
   * 所有库存记录增加库存数量,并且记录增加操作记录.
   *
   * @param skuStockAndAllRecursionParentStocks 所有库存记录（包含sku与商品库存）
   * @param wmsStockBatchRecord 批量操作记录
   * @param skuWmsStockRecords sku库存操作记录
   */
  void addSkuStockAndAutoCalcRecursionParentStocks(List<WmsStock> skuStockAndAllRecursionParentStocks, WmsStockBatchRecord wmsStockBatchRecord, List<WmsStockRecord> skuWmsStockRecords);

  /**
   * 所有库存记录扣减库存数量,并且记录扣减操作记录.
   *
   * @param skuStockAndAllRecursionParentStocks 所有库存记录（包含sku与商品库存）
   * @param wmsStockBatchRecord 批量操作记录
   * @param skuWmsStockRecords sku库存操作记录
   */
  void subtractSkuStockAndCalcRecursionParentStocks(List<WmsStock> skuStockAndAllRecursionParentStocks, WmsStockBatchRecord wmsStockBatchRecord, List<WmsStockRecord> skuWmsStockRecords);

  /**
   * 调用{@link this#addSkuStockAndAutoCalcRecursionParentStocks} or {@link this#subtractSkuStockAndCalcRecursionParentStocks}.
   *
   *  @param actionTypeEnum 操作类型 ,仅支持{@link WmsStockRecordActionTypeEnum#ADD} and {@link WmsStockRecordActionTypeEnum#SUBTRACT}
   */
  void addOrSubtractSkuStockAndCalcRecursionParentStocks(List<WmsStock> skuStockAndAllRecursionParentStocks, WmsStockBatchRecord wmsStockBatchRecord, List<WmsStockRecord> skuWmsStockRecords,
      WmsStockRecordActionTypeEnum actionTypeEnum);

  /**
   * 修改库存,增加、扣减与设置库存,并且记录对应操作记录
   *
   * @param skuStockAndAllRecursionParentStocks 所有库存记录（包含sku与商品库存）
   * @param wmsStockBatchRecord 批量操作记录
   * @param skuWmsStockRecords sku库存操作记录
   */
  void modifySkuStockAndCalcRecursionParentStocks(List<WmsStock> skuStockAndAllRecursionParentStocks, WmsStockBatchRecord wmsStockBatchRecord, List<WmsStockRecord> skuWmsStockRecords);

  /**
   *  回退相关库存操作记录,并且记录操作记录.
   *
   * @param skuStockAndAllRecursionParentStocks 所有库存记录（包含sku与商品库存）
   * @param wmsStockBatchRecord 批量操作记录
   * @param reverseWmsStockRecords 回退sku库存操作记录
   */
  void reverseAndCalcRecursionParentStocks(List<WmsStock> skuStockAndAllRecursionParentStocks, WmsStockBatchRecord wmsStockBatchRecord, List<WmsStockRecord> reverseWmsStockRecords);
}